package br.edu.sistemaacademico;

import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

import br.edu.sistemaacademico.Decorator.ConcretDecorator;
import br.edu.sistemaacademico.adapter.IMenuCadastro;
import br.edu.sistemaacademico.observer.Observavel;
import br.edu.sistemaacademico.observer.Observer;
import br.edu.sistemaacademico.observer.ValidaEspecial;
import br.edu.sistemaacademico.pojo.Servidor;
import client.ClientCommand;

public class frmAtualizaServidor extends IMenuCadastro {

    Servidor servidor = new Servidor();
    ConcretDecorator cc = null;
    public frmAtualizaServidor(Servidor servidor) {
            this.servidor = servidor;
            execute();
    }

        @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        JtbRG = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtbDtNasc = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        JtbLogin = new javax.swing.JTextField();
        jLEndereco = new javax.swing.JLabel();
        JtbSenha = new javax.swing.JPasswordField();
        jTEndereco = new javax.swing.JTextField();
        jLCidade = new javax.swing.JLabel();
        jTCPF = new javax.swing.JTextField();
        JtbSenharetry = new javax.swing.JPasswordField();
        jLTelefone = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTTelefone = new javax.swing.JTextField();
        JtbCTPS = new javax.swing.JTextField();
        infoBairro1 = new javax.swing.JLabel();
        infoBairro2 = new javax.swing.JLabel();
        infoBairro3 = new javax.swing.JLabel();
        infoBairro4 = new javax.swing.JLabel();
        jTsexo = new javax.swing.JTextField();
        infoBairro5 = new javax.swing.JLabel();
        jLBairro = new javax.swing.JLabel();
        infoBairro6 = new javax.swing.JLabel();
        infoTelefone = new javax.swing.JLabel();
        infoBairro = new javax.swing.JLabel();
        infoCidade = new javax.swing.JLabel();
        infoEndereco = new javax.swing.JLabel();
        jtbCargo = new javax.swing.JTextField();
        jBCancelar = new javax.swing.JButton();
        jBCadastrar = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        JtbEscolaridade = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLNome = new javax.swing.JLabel();
        jTNome = new javax.swing.JTextField();
        infoNome = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(430, 194));

        jPanel1.setPreferredSize(new java.awt.Dimension(522, 494));

        jLabel1.setText("RG");

        JtbRG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JtbRGActionPerformed(evt);
            }
        });

        jLabel4.setText("Senha");

        jLabel2.setText("Data Nascimento");

        jLabel3.setText("Login");

        jLabel5.setText("Repita Senha");

        jLEndereco.setText("Endereco");

        JtbSenha.setText("jPasswordField1");

        jLCidade.setText("CPF");

        JtbSenharetry.setText("jPasswordField2");

        jLTelefone.setText("Telefone");

        jLabel6.setText("CTPS");

        jTTelefone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTTelefoneActionPerformed(evt);
            }
        });

        infoBairro1.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro1.setText("* Campo Obrigatorio");

        infoBairro2.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro2.setText("* Campo Obrigatorio");

        infoBairro3.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro3.setText("* Campo Obrigatorio");

        infoBairro4.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro4.setText("* Campo Obrigatorio");

        jTsexo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTsexoActionPerformed(evt);
            }
        });

        infoBairro5.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro5.setText("* Campo Obrigatorio");

        jLBairro.setText("Sexo");

        infoBairro6.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro6.setText("* Campo Obrigatorio");

        infoTelefone.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoTelefone.setText(" ");

        infoBairro.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro.setText("* Campo Obrigatorio");

        infoCidade.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoCidade.setText("* Campo Obrigatorio");

        infoEndereco.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoEndereco.setText("* Campo Obrigatorio");

        jBCancelar.setText("Cancelar");
        jBCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCancelarActionPerformed(evt);
            }
        });

        jBCadastrar.setText("Cadastrar");
        jBCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCadastrarActionPerformed(evt);
            }
        });

        jLabel10.setText("Cargo");

        jLabel9.setText("Escolaridade");

        jLNome.setText("Nome");

        infoNome.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoNome.setText("* Campo Obrigatorio");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLEndereco)
                                            .addComponent(jLCidade)
                                            .addComponent(jLabel1)
                                            .addComponent(jLabel6)
                                            .addComponent(jLTelefone))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jTTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 247, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(infoEndereco)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 297, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(infoCidade)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 297, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jTEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(jTCPF, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                                                        .addGap(38, 38, 38))
                                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(infoBairro)
                                                            .addComponent(JtbRG, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)
                                                            .addComponent(JtbCTPS, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE))
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                                .addComponent(jLBairro)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jTsexo, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(27, 27, 27))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(infoBairro2)
                                                .addGap(9, 9, 9))
                                            .addComponent(jTNome, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(infoBairro1)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 297, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(infoNome)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(38, 38, 38)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(infoBairro6)
                                            .addComponent(JtbSenharetry, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel2)
                                            .addComponent(jLabel3)
                                            .addComponent(jLabel4))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(infoBairro4)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jtbDtNasc, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 265, Short.MAX_VALUE))
                                                .addComponent(infoBairro3, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(infoBairro5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                                                .addComponent(JtbSenha, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(JtbLogin, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addGap(23, 23, 23))
                            .addComponent(jLNome))
                        .addGap(22, 22, 22))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(133, 133, 133)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(jBCadastrar)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jBCancelar))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(JtbEscolaridade, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jtbCargo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 403, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 452, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(210, 210, 210)
                    .addComponent(infoTelefone)
                    .addGap(279, 279, 279)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(infoNome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLNome)
                    .addComponent(jTNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(infoEndereco)
                        .addGap(2, 2, 2)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLEndereco)
                            .addComponent(jTEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(infoCidade)
                                .addGap(3, 3, 3)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLCidade)
                                    .addComponent(jTCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(infoBairro)
                                .addGap(2, 2, 2)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(JtbRG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLBairro)
                                    .addComponent(jTsexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(6, 6, 6)
                        .addComponent(infoBairro1)
                        .addGap(2, 2, 2)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(JtbCTPS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLTelefone)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(144, 144, 144)
                        .addComponent(infoBairro2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(infoBairro3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtbDtNasc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(infoBairro4)
                        .addGap(2, 2, 2)
                        .addComponent(JtbLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(infoBairro5)
                        .addGap(1, 1, 1)
                        .addComponent(JtbSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(7, 7, 7)
                        .addComponent(infoBairro6)
                        .addGap(1, 1, 1))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JtbSenharetry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(JtbEscolaridade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jtbCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBCadastrar)
                    .addComponent(jBCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(160, 160, 160)
                    .addComponent(infoTelefone)
                    .addContainerGap(324, Short.MAX_VALUE)))
        );

        jScrollPane1.setViewportView(jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 549, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

        private void JtbRGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JtbRGActionPerformed
            // TODO add your handling code here:
}//GEN-LAST:event_JtbRGActionPerformed

        private void jTTelefoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTTelefoneActionPerformed
            System.out.println("telefone");
}//GEN-LAST:event_jTTelefoneActionPerformed

        private void jTsexoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTsexoActionPerformed
            // TODO add your handling code here:
}//GEN-LAST:event_jTsexoActionPerformed

        private void jBCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCancelarActionPerformed

}//GEN-LAST:event_jBCancelarActionPerformed

        private void jBCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCadastrarActionPerformed

}//GEN-LAST:event_jBCadastrarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField JtbCTPS;
    private javax.swing.JTextField JtbEscolaridade;
    private javax.swing.JTextField JtbLogin;
    private javax.swing.JTextField JtbRG;
    private javax.swing.JPasswordField JtbSenha;
    private javax.swing.JPasswordField JtbSenharetry;
    private javax.swing.JLabel infoBairro;
    private javax.swing.JLabel infoBairro1;
    private javax.swing.JLabel infoBairro2;
    private javax.swing.JLabel infoBairro3;
    private javax.swing.JLabel infoBairro4;
    private javax.swing.JLabel infoBairro5;
    private javax.swing.JLabel infoBairro6;
    private javax.swing.JLabel infoCidade;
    private javax.swing.JLabel infoEndereco;
    private javax.swing.JLabel infoNome;
    private javax.swing.JLabel infoTelefone;
    private javax.swing.JButton jBCadastrar;
    private javax.swing.JButton jBCancelar;
    private javax.swing.JLabel jLBairro;
    private javax.swing.JLabel jLCidade;
    private javax.swing.JLabel jLEndereco;
    private javax.swing.JLabel jLNome;
    private javax.swing.JLabel jLTelefone;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTCPF;
    private javax.swing.JTextField jTEndereco;
    private javax.swing.JTextField jTNome;
    private javax.swing.JTextField jTTelefone;
    private javax.swing.JTextField jTsexo;
    private javax.swing.JTextField jtbCargo;
    private javax.swing.JTextField jtbDtNasc;
    // End of variables declaration//GEN-END:variables
    
    private Observavel docTelefone = new Observavel();
    private Observavel docNome = new Observavel();
    private Observavel docBairro = new Observavel();
    private Observavel docEndereco = new Observavel();
    private Observavel docCidade = new Observavel();


    public void execute() {
         initComponents();
         if (cc==null)
                cc = new ConcretDecorator(this);
          

          populaFields(servidor);
          initObserver();
          campoObrigatorio();
          cc.setVisible(true);
    }

    public void initObserver(){
        Observer val = new ValidaEspecial();
        docTelefone.setDocument(jTTelefone.getDocument());
          docNome.setDocument(jTNome.getDocument());
          docBairro.setDocument(jTsexo.getDocument());
          docEndereco.setDocument(jTEndereco.getDocument());
          docCidade.setDocument(jTCPF.getDocument());

          docTelefone.addObserver(val);
          docNome.addObserver(val);
          docBairro.addObserver(val);
          docEndereco.addObserver(val);
          docCidade.addObserver(val);


          jTTelefone.getDocument().addDocumentListener(listener);
          jTNome.getDocument().addDocumentListener(listener);
          jTsexo.getDocument().addDocumentListener(listener);
          jTEndereco.getDocument().addDocumentListener(listener);
          jTCPF.getDocument().addDocumentListener(listener);
    }

    public void setTtelefone(Observavel observavel){
        observavel.setDocument(jTTelefone.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTTelefone.setDocument(observavel.getDocument());

    }
        public void setTNome(Observavel observavel){
        observavel.setDocument(jTNome.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTNome.setDocument(observavel.getDocument());
    }
        public void setTBairro(Observavel observavel){
        observavel.setDocument(jTsexo.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTsexo.setDocument(observavel.getDocument());
    }
        public void setTEndereco(Observavel observavel){
        observavel.setDocument(jTEndereco.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTEndereco.setDocument(observavel.getDocument());
    }
        public void setTCidade(Observavel observavel){
        observavel.setDocument(jTCPF.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTCPF.setDocument(observavel.getDocument());
    }

    public void getEventDocument(Document doc){
        if(doc.equals(docTelefone.getDocument()))
                setTtelefone(docTelefone);
        else if(doc.equals(docNome.getDocument()))
                setTNome(docNome);
        else if(doc.equals(docBairro.getDocument()))
                setTBairro(docBairro);
        else if(doc.equals(docEndereco.getDocument()))
                setTEndereco(docEndereco);
        else if(doc.equals(docCidade.getDocument()))
                setTCidade(docCidade);
    }

    public void campoObrigatorio(){
        infoNome.setText("* Campo Obrigatorio");
        infoEndereco.setText("* Campo Obrigatorio");
        infoCidade.setText("* Campo Obrigatorio");
        infoBairro.setText("* Campo Obrigatorio");
    }
    
    DocumentListener listener = new DocumentListener() {

            public void insertUpdate(DocumentEvent e) {
               getEventDocument(e.getDocument());
            }

            public void removeUpdate(DocumentEvent e) {
                getEventDocument(e.getDocument());
            }

            public void changedUpdate(DocumentEvent e) {
                 getEventDocument(e.getDocument());
            }

        };

            public void populaServidor(Servidor o){
        o.setNome(jTNome.getText());
        o.setEndereco(jTEndereco.getText());
        o.setCpf(jTCPF.getText());
        o.setTelefone(jTTelefone.getText());
        o.setSexo(jTsexo.getText().charAt(0));
        o.setRg(JtbRG.getText());
        o.setNascimento(jtbDtNasc.getText());
        o.setLogin(JtbLogin.getText());
        if(JtbSenha.getText().equals(JtbSenharetry.getText()))
        o.setSenha(JtbSenha.getText());
        o.setCtps(JtbCTPS.getText());
        o.setEscolaridade(JtbEscolaridade.getText());
        o.setCargo(jtbCargo.getText());
        //o.setAnosaida(JtbDtSaida.getText());
    }
    public void populaFields(Servidor o){
        jTNome.setText(o.getNome());
        jTEndereco.setText(o.getEndereco());
        jTCPF.setText(o.getCpf());
        jTTelefone.setText(o.getTelefone());
        jTsexo.setText(o.getSexo().toString());
        JtbRG.setText(o.getRg());
        jtbDtNasc.setText(o.getNascimento());
        JtbLogin.setText(o.getLogin());
        JtbSenha.setText(o.getSenha());
        JtbSenharetry.setText(o.getSenha());
        JtbCTPS.setText(o.getCtps());
        JtbEscolaridade.setText(o.getEscolaridade());
        jtbCargo.setText(o.getCargo());

    }
    public void limpaFields(){
        jTNome.setText("");
        jTEndereco.setText("");
        jTCPF.setText("");
        jTTelefone.setText("");
        jTsexo.setText("");
        JtbRG.setText("");
        jtbDtNasc.setText("");
        JtbLogin.setText("");
        JtbSenha.setText("");
        JtbSenharetry.setText("");
        JtbCTPS.setText("");
        JtbEscolaridade.setText("");
        jtbCargo.setText("");
    }

    
	@Override
	public void menuExemplo(JMenuItem item) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void menuFechar(JMenuItem item) {
		cc.dispose();		
	}

	@Override
	public void menuLimpa(JMenuItem item) {
		limpaFields();		
	}

	@Override
	public void menuManual(JMenuItem item) {
		// TODO Auto-generated method stub		
	}

	@Override
	public void menuMementor(JMenuItem item) {
		// TODO Auto-generated method stub		
	}

	@Override
	public void menuOperacao(JMenuItem item) {
		item.setText("Cadastrar Servidor");
		operacao();
	}

	@Override
	public void menuSobre(JMenuItem item) {
		// TODO Auto-generated method stub
		
	}
	
	public void operacao(){
    	populaServidor(servidor);
       
        if( ClientCommand.alterar("ServidorService",servidor)==true)
        	JOptionPane.showMessageDialog(null, "Servidor Cadastrado com sucesso");
        limpaFields();
	}

}
